from django import forms
from django.contrib.auth.forms import AuthenticationForm


class RoleLoginForm(AuthenticationForm):
    ROLE_CHOICES = [
        ('user', '普通用户'),
        ('admin', '管理员'),
        ('culture', '文旅机构'),
    ]

    role = forms.ChoiceField(
        choices=ROLE_CHOICES,
        widget=forms.RadioSelect(attrs={'class': 'btn-check'}),
        initial='user'
    )

    remember_me = forms.BooleanField(
        required=False,
        widget=forms.CheckboxInput(attrs={'class': 'form-check-input'})
    )

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['username'].widget.attrs.update({'class': 'form-control', 'placeholder': '请输入用户名'})
        self.fields['password'].widget.attrs.update({'class': 'form-control', 'placeholder': '请输入密码'})